<template>
  <div class="search">
    <f-form ref="form" :action="api.vipcard" :form-key="this.formItem.vipcardId" >
      <f-form-item label="卡分类"  name="vipcardCategoryId" dataType="${formField.dataType}"   :value="formItem.vipcardCategoryId" />
      <f-form-item label="卡种编号"  name="vipCardNumber" dataType="${formField.dataType}"   :value="formItem.vipCardNumber" />
      <f-form-item label="续卡价格"  name="newPrice" dataType="${formField.dataType}"   :value="formItem.newPrice" />
      <f-form-item label="卡协议"  name="agreement" dataType="${formField.dataType}"   :value="formItem.agreement" />
      <f-form-item label="计费方式（1期间卡 2计次卡）"  name="billingWay" dataType="number"   :value="formItem.billingWay" />
      <f-form-item label="权益简介"  name="vipcardDesc" dataType="${formField.dataType}"   :value="formItem.vipcardDesc" />
      <f-form-item label="卡号前缀"  name="prefixNo" dataType="${formField.dataType}"   :value="formItem.prefixNo" />
      <f-form-item label="卡号后缀"  name="suffixNo" dataType="${formField.dataType}"   :value="formItem.suffixNo" />
      <f-form-item label="卡号公共"  name="commonNo" dataType="number"   :value="formItem.commonNo" />
      <f-form-item label="（续卡卡种（1是，2不是））"  name="isContinue" dataType="number"   :value="formItem.isContinue" />
      <f-form-item label="是否包含区域号（卡号规则1包含,2不包含）"  name="isContainArea" dataType="number"   :value="formItem.isContainArea" />
      <f-form-item label=""  name="firstRecommend" dataType="number"   :value="formItem.firstRecommend" />
      <f-form-item label="会员卡排序"  name="vipcardSort" dataType="number"   :value="formItem.vipcardSort" />
      <f-form-item label=""  name="useWeChatId" dataType="${formField.dataType}"   :value="formItem.useWeChatId" />
      <f-form-item label="去掉前缀后缀区域号的最大部分"  name="maxVipcardNo" dataType="${formField.dataType}"   :value="formItem.maxVipcardNo" />
      <f-form-item label=""  name="isSyncVip" dataType="number"   :value="formItem.isSyncVip" />
      <f-form-item label=""  name="isTakePeople" dataType="number"   :value="formItem.isTakePeople" />
      <f-form-item label="是否是体验卡种（0不是，1是）"  name="isTiyan" dataType="number"   :value="formItem.isTiyan" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'vipcardForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          vipcardId: '',
          vipcardCategoryId: '',
          vipCardNumber: '',
          newPrice: '',
          agreement: '',
          billingWay: '',
          vipcardDesc: '',
          prefixNo: '',
          suffixNo: '',
          commonNo: '',
          isContinue: '',
          isContainArea: '',
          firstRecommend: '',
          vipcardSort: '',
          useWeChatId: '',
          maxVipcardNo: '',
          isSyncVip: '',
          isTakePeople: '',
          isTiyan: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.vipcardId) {
          let params={
              vipcardId:data.vipcardId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
